/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.businessarchives.SearchEngine;
/*    */ import com.newcrm.exception.CaptchaException;
/*    */ import com.newcrm.exception.NotFoundException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import java.util.Map;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class ShowCompanyBusinessArchives extends AbstractAction
/*    */ {
/* 25 */   private static Logger logger = Logger.getLogger(ShowCompanyBusinessArchives.class.getName());
/*    */ 
/*    */   public ShowCompanyBusinessArchives(AbstractHttpServlet servlet) {
/* 28 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException, NotFoundException
/*    */   {
/* 35 */     response.setContentType("text/html;charset=utf-8");
/* 36 */     PrintWriter out = response.getWriter();
/* 37 */     JSONObject jsonObject = new JSONObject();
/*    */ 
/* 39 */     String name = Util.getURLParameter(request.getParameter("name"));
/*    */ 
/* 41 */     SearchEngine searchEngine = SearchEngine.getInstance(name);
/* 42 */     if (searchEngine == null) {
/* 43 */       logger.warn("searchEngine is null " + name);
/* 44 */       jsonObject.put("error", "1");
/* 45 */       out.println(jsonObject);
/* 46 */       out.flush();
/* 47 */       out.close();
/* 48 */       return;
/*    */     }
/*    */ 
/* 52 */     String captcha = Util.getURLParameter(request.getParameter("captcha"));
/* 53 */     searchEngine.setCaptcha(captcha);
/*    */ 
/* 56 */     String refresh = Util.getURLParameter(request.getParameter("refresh"));
/* 57 */     boolean isRefresh = "1".equals(refresh);
/*    */ 
/* 59 */     Map result = null;
/*    */     try {
/* 61 */       result = searchEngine.getCompanyInfo(isRefresh);
/*    */     }
/*    */     catch (CaptchaException e) {
/* 64 */       jsonObject.put("error", "2");
/* 65 */       out.println(jsonObject);
/* 66 */       out.flush();
/* 67 */       out.close();
/* 68 */       return;
/*    */     }
/* 70 */     if ((result == null) || (result.size() == 0)) {
/* 71 */       logger.warn("not find company " + name);
/* 72 */       jsonObject.put("error", "1");
/* 73 */       out.println(jsonObject);
/* 74 */       out.flush();
/* 75 */       out.close();
/* 76 */       return;
/*    */     }
/* 78 */     jsonObject.put("error", "0");
/* 79 */     jsonObject.put("info", result);
/* 80 */     out.println(jsonObject);
/* 81 */     out.flush();
/* 82 */     out.close();
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.ShowCompanyBusinessArchives
 * JD-Core Version:    0.6.1
 */